package com.xrz.sxm.base.activity;

import com.huobao.zhangying.R;
import com.xrz.sxm.base.utils.QuitLoopHandle;

import android.app.Activity;
import android.os.Bundle;
import android.view.Display;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;

public class Activity_MessageBox extends Activity {

	private TextView m_Title;
 
	private TextView m_Content;

	private Button btn_1;
	private Button btn_2;
	private Button btn_3;

	public static boolean isQueding = false;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.layout_dialog);
		initData();
	}

	protected void initData() {
		WindowManager m = getWindowManager();
		Display d = m.getDefaultDisplay(); // 为获取屏幕宽、高

		WindowManager.LayoutParams p = getWindow().getAttributes(); // 获取对话框当前的参数值
		p.height = (int) (d.getHeight() * 1.0); // 高度设置为屏幕的1.0
		p.width = (int) (d.getWidth() * 0.7); // 宽度设置为屏幕的0.8
		p.alpha = 1.0f; // 设置本身透明度
		p.dimAmount = 0.0f; // 设置黑暗度

		getWindow().setAttributes(p); // 设置生效
		getWindow().setGravity(Gravity.RIGHT); // 设置靠右对齐

		m_Title = (TextView) findViewById(R.id.tv_title);
		m_Content = (TextView) findViewById(R.id.tv_content);
		btn_1 = (Button) findViewById(R.id.btn_1);
		btn_2 = (Button) findViewById(R.id.btn_2);
		btn_3 = (Button) findViewById(R.id.btn_3);

		m_Title.setText("升级提醒");
		m_Content.setText(getIntent().getStringExtra("message"));
		btn_3.setVisibility(View.GONE);
		btn_1.setText("升级");
		btn_2.setText("取消");
		btn_1.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				isQueding = true;
				QuitLoopHandle.QuitLoop();
				finish();
			}
		});
		btn_2.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				isQueding = false;
				QuitLoopHandle.QuitLoop();
				finish();
			}
		});
	}

}
